package com.yuan.aopbefore;


import org.springframework.stereotype.Component;

@Component
public class MyStaticProxy implements Calc {

    //目标对象
    private CalcImpl calcImpl;

    public MyStaticProxy(CalcImpl calcImpl) {
        this.calcImpl = calcImpl;
    }

    @Override
    public int add(int i, int j) {
        //执行方法之前,记录日志
        MyLogging.methodBefore("add",i,j);
        //执行目标对象的加法
        int rs = calcImpl.add(i, j);
        //执行方法之后,记录日志
        MyLogging.methodAfter("add",rs);
        return rs;
    }

    @Override
    public int sub(int i, int j) {
        MyLogging.methodBefore("sub",i,j);
        //执行目标对象的减法
        int rs = calcImpl.sub(i, j);
        MyLogging.methodAfter("sub",rs);
        return rs;
    }

    @Override
    public int mul(int i, int j) {
        return 0;
    }

    @Override
    public int div(int i, int j) {
        return 0;
    }
}